﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestPlatform.Core;
using System.Data.SqlClient;
using TestPlatform.Performer.Mssql.EF.Entities;

namespace TestPlatform.Performer.Mssql.EF
{
    public class MssqlEFInsertPerformer : BaseInsertPerformer
    {   
        public override string UnderlyinEngine { get { return "Mssql - EF"; } }

        public MssqlEFInsertPerformer()
            : base(new MssqlHelper())
        {

        }

        protected override void InsertEntity()
        {
            using (var c = new RepositoryContext())
            {
                User u = new User { Id = Guid.NewGuid(), Login = Guid.NewGuid().ToString(), Name = Guid.NewGuid().ToString() };
                c.Users.Add(u);

                for (int i = 0; i < TestConfig.InsertSubEntitiesCount; i++)
                {
                    c.Posts.Add(new Post { Id = Guid.NewGuid(), Text = Guid.NewGuid().ToString(), User = u });
                }

                c.SaveChanges();
            }
        }       
    }
}
